require "Common/define"
require "Logic/Config"
require "Common/functions"
require "Net/skillHandler"

UISupSkill = {};
HelperFunc.SetUIEnv(UISupSkill)
local this = UISupSkill;

this.idleTimer = nil;
this.btn_Prev = nil;
this.btn_Next = nil;
this.btnLook = nil;
this.btn_DrawOne = nil;
this.btn_DrawTen = nil;
this.btn_Shop = nil;
this.skillIdx = nil;--技能索引
this.curItem = nil;--当前的item
this.skillNameText = nil;--技能名称
this.skillLevelText = nil;--技能等级
this.tipsIcon = nil;--技能图标
this.skillTipsText = nil;--技能信息
this.allSkillData = nil;--所有技能的数据
this.allSkillItems = nil;--所有可滚动的item合集
this.content = nil;
this.backBtn = nil;
this.indexController = nil;
this.upgradeController = nil;
this.liHuiPos = nil;
this.liHuiSpine = nil;
this.hasInt = false;
this.isCanUpgrade = false;
this.title = nil
this.cash = nil
this.coin = nil
this.nextBtn = nil;
this.lastBtn = nil;
this.oneIcon = nil;
this.tenIcon = nil;
this.buyTime = nil;
this.upgradeBtn = nil;
this.consumeList = nil;
this.skillInfo = nil;
this.skillGroup = {};
this.isScroll = false;
this.resTab = {}
this.img_Icon = nil;
this.txt_name = nil;
this.txt_level = nil;
this.btn_head = nil;
this.exp = nil;
this.bg = nil;
this.btnWish = nil;
this.showTipBtn = nil;
this.gameObject = nil;
this.costIdList = {};
this.btnShop = nil; --快捷购买
this.curAttr = {}
this.nextAttr = {}
this.attributeShowConfig = nil

UISupSkill.OpenState = {}

local SHOP_ID = 11000
function UISupSkill.Init()
    local allSkill = G.dataTable["t_assistantskill"];
    skillGroup = logicMgr.SkillManager.getSupSkillConfig();

    local name, packageName = getUIName(PanelNames.UISupSkill);
    panelMgr:Push(name, packageName, this.onCreate, Config.useLocalUI);
end

--定义控件
function UISupSkill.onCreate(obj)
    if not hasInt then
        gameObject = obj;
        --btn_Prev = transform:Find("btnpre");
        --btn_Next = transform:Find("btnnext");
        indexController = obj:GetController("skillIndex");
        indexController:SetSelectedIndex(0);
        skillIdx = 0;
        content = obj:GetChild("supskill");
        consumeList = obj:GetChild("needitem");
        skillNameText = obj:GetChild("SkillName");
        skillTipsText = obj:GetChild("SkillTips");
        liHuiPos = obj:GetChild("lihui");
        tipsIcon = obj:GetChild("TipsIcon");
        showTipBtn = obj:GetChild("info")
        nextBtn = obj:GetChild("right");
        lastBtn = obj:GetChild("left");
        backBtn = obj:GetChild("backBtn");
        upgradeBtn = obj:GetChild("upgrade");
        skillLevelText = upgradeBtn:GetChild("SkillLevel");
        upgradeController = upgradeBtn:GetController("upgrade");

        curAttrList = obj:GetChild("listAttr");
        nextAttrList = obj:GetChild("listAttrNext");
        previewBtn = obj:GetChild("btnPreview");
        previewCtrl = obj:GetController("attrPreview");
        levelMaxCtrl = obj:GetController("ifLevelMax");
        this.sourceUIobj = obj:GetChild("UISourceMultiple");
        this.showSourceController = obj:GetController("showSource")
        this.btnSource = obj:GetChild("btnSource");
        this.effectController = this.btnSource:GetController("effect");
        this.btnShop = obj:GetChild("ShopBtn");
        resetBtn = obj:GetChild("resetSkill")
        for i = 1, 7 do
            local idx = 8 - i;
            if idx > #skillGroup then
                obj:GetChild("point" .. idx).visible = false;
            else
                break ;
            end

        end

        resMgr:LoadModelPrefab("Model/Drawing/drawing_hero_10002", function(go)
            local drawWrapper = GoWrapper.New();

            if (liHuiSpine ~= nil) then
                destroyImmediate(liHuiSpine);
                liHuiSpine = nil
            end

            liHuiSpine = newObject(go);
            liHuiSpine:AddComponent(TCanvas);
            Util.AddAction(liHuiSpine, "idle1", true, 0);

            drawWrapper:SetWrapTarget(liHuiSpine, false)
            Util.Lua_SetLocalPositionXYZ(liHuiSpine.transform, 0, 0, 0)
            Util.Lua_SetLocalScaleXYZ(liHuiSpine.transform, 0.8, 0.8, 1)
            liHuiPos:SetNativeObject(drawWrapper);
        end)

        this.addEvent()
    end
    
    skillHandler.SendReqAssistantSkill()

    --this.refreshHead()
    --this.updatePage();
    --this.updateRes();
    buyTime = 0;
    if RedDotsAssistantSkillHandler.HasRedPoint() then
        RedDotsAssistantSkillHandler.RedTipToday()
    end
    this.refreshShop();
end

function UISupSkill.upgradeSuccess()
    skillInfo = logicMgr.SkillManager.getSupSkillInfo();
    local g = liHuiSpine:GetComponent("SkeletonGraphic")
    g.AnimationState:SetAnimation(0, "idle2", false);
    local idleAniTime = g.AnimationState.Data.SkeletonData:FindAnimation("idle2").Duration;
    if idleTimer == nil then
        idleTimer = Timer.New(this.delayIdle, idleAniTime, 1, false);
    else
        idleTimer:Reset(this.delayIdle, idleAniTime, 1, false);
    end
    idleTimer:Start();
    this.initPapers();
    this.onClickChangePage();


end

function UISupSkill.delayIdle()
    -- 调用loop的idea
    if not HelperFunc.IsNull(liHuiSpine) then
        liHuiSpine:GetComponent("SkeletonGraphic").AnimationState:SetAnimation(0, "idle1", true);
    end
end

function UISupSkill.updateRes()
    --cash.text = this.getDrawResNum(resTab[1]);
    --coin.text = this.getDrawResNum(resTab[3]);
end

function UISupSkill.onClose()
    closeUI(PanelNames.UISupSkill);
end

function UISupSkill.addEvent()
    indexController.onChanged:Add(this.onIndexChanged);
    upgradeBtn.onClick:Add(this.upgradeSkill);
    nextBtn.onClick:Add(this.scrollToNext);
    lastBtn.onClick:Add(this.scrollToLast);
    backBtn.onClick:Add(this.onClose);
    previewBtn.onClick:Add(this.onClickPreview);
    content.onClickItem:Add(this.scrollToItem);
    showTipBtn.onClick:Add(this.openTips);
    this.btnSource.onClick:Add(this.onClickSource)
    resetBtn.onClick:Add(this.onClickResetSkill)
    ListenEvent(Config.EventType.AssistantSkill, this.setInfo);
    ListenEvent(Config.EventType.Fresh_AssistantSkillReset, this.setInfo);
    ListenEvent(Config.EventType.LevUpAssistantSkill, this.upgradeSuccess);
    ListenEvent(Config.EventType.Fresh_Bag, this.updateSource);
    ListenEvent(Config.EventType.Fresh_BagUseItemBack, logicMgr.ItemManager.showGetItem);
    UIRedDots.addViewListen(PanelNames.UISupSkill, "UISupSkill", upgradeBtn, Config.RedDotsType.AssistantSkill);
    this.btnShop.onClick:Add(this.onClickShop);
end

function UISupSkill.removeEvent()
    indexController.onChanged:Remove(this.onIndexChanged);
    upgradeBtn.onClick:Remove(this.upgradeSkill);
    backBtn.onClick:Remove(this.onClose);
    nextBtn.onClick:Remove(this.scrollToNext);
    lastBtn.onClick:Remove(this.scrollToLast);
    content.onClickItem:Remove(this.scrollToItem);
    showTipBtn.onClick:Remove(this.openTips);
    resetBtn.onClick:Remove(this.onClickResetSkill);

    this.btnSource.onClick:Remove(this.onClickSource)

    CloseEvent(Config.EventType.AssistantSkill, this.setInfo);
    CloseEvent(Config.EventType.Fresh_AssistantSkillReset, this.setInfo);
    CloseEvent(Config.EventType.LevUpAssistantSkill, this.upgradeSuccess);
    CloseEvent(Config.EventType.Fresh_Bag, this.updateSource);
    CloseEvent(Config.EventType.Fresh_BagUseItemBack, logicMgr.ItemManager.showGetItem);
    UIRedDots.removeViewEvent(PanelNames.UISupSkill);
    this.btnShop.onClick:Remove(this.onClickShop);
end

function UISupSkill.scrollToNext(evt)
    content.scrollPane:ScrollRight(1, true);
    --local changeIdx = content:GetChildIndex(curItem) - 2;
    --content:ScrollToView(changeIdx, true);
end

function UISupSkill.scrollToLast(evt)
    content.scrollPane:ScrollLeft(1, true);

    --local changeIdx = content:GetChildIndex(curItem) + 2;
    --content:ScrollToView(changeIdx, true);

end

function UISupSkill.openTips()
    local txts = {};
    txts["title"] = "SupSkillHelpTitle01";
    txts["des"] = "SupSkillHelpText01";
    txts["story"] = "FunctionStory612";
    showUI(PanelNames.CommonTips, txts);
end

function UISupSkill.setInfo()
    skillInfo = logicMgr.SkillManager.getSupSkillInfo();
    this.initPapers();

end

function UISupSkill.upgradeSkill()
    if this.last_click_time and UnityEngineTime.realtimeSinceStartup-this.last_click_time < 1 then
        --点太快会触发多次
        return
    end
    this.last_click_time = UnityEngineTime.realtimeSinceStartup
    for i = 1, #allSkillData[skillIdx + 1].data.f_Cost do
        local curData = allSkillData[skillIdx + 1].data.f_Cost[i];
        local hasNum = logicMgr.ItemManager.getCurrencyCountByModelId(curData[1]);
        if curData[2] > hasNum then
            UISysTips.AddMsg(string.format(getLanguage("Character_Tips19"), logicMgr.ItemManager.GetItemName(curData[1])));
            return;
        end
    end

    --未解锁
    local curData = allSkillData[skillIdx + 1];
    if curData.data.f_GetCondition[1][2] > logicMgr.MapManager.getMapId() then
        UISysTips.AddMsg((getLanguage("AssistantSkillTitle01")));
        return;
    end

    --等级达到上限
    local curGroup = skillGroup[curData.data.f_AssistantSkillGroup];
    if #curGroup < SkillManager.supSkillLv + 1 then
        UISysTips.AddMsg((getLanguage("AssistantSkillTitle02")));
        return;
    end

    skillHandler.SendLevUpAssistantSkill(allSkillData[skillIdx + 1].id);
    skillHandler.SendReqAssistantSkill()
end

function UISupSkill.scrollToItem(evt)

    local go = evt.data
    local midX = content.scrollPane.posX + content.viewWidth / 2
    if go.x > midX then
        content.scrollPane:ScrollRight(1, true)
    else
        content.scrollPane:ScrollLeft(1, true)
    end
    --local index = content:GetChildIndex(go)
    --
    --content:ScrollToView(index, true)
end

function UISupSkill.OnDestroy()
    hasInt = nil
    if liHuiSpine then
        destroyImmediate(liHuiSpine)
        liHuiSpine = nil
    end
    this.removeEvent();
    --if not isOpenUI(PanelResNames.UIHeadMenu) then
    --    showUI(PanelNames.UIHeadMenu)
    --end
end

function UISupSkill.OnEnable()
    buyTime = 0;
    --closeUI(PanelResNames.UIHeadMenu);
end

function UISupSkill.OnDisable()
    buyTime = 0;
    isScroll = false;
    hasInt = false;
    --if not isOpenUI(PanelResNames.UIHeadMenu) then
   --     showUI(PanelNames.UIHeadMenu)
   -- end
end

function UISupSkill.onIndexChanged(evt)
    print(evt)
end
--[[
function UISupSkill.onClickPrevPage()
    curpage = curpage - 1;
    if curpage < 1 then
        curpage = #tab_top;
    end
    --activityPage.transform:DOLocalMoveX((curpage-1)*-720-360,0.4,false);   ---720*(curpage-2)
    this.ClickPage();
end
]]

--[[function UISupSkill.onClickNextPage()
    curpage = curpage + 1;
    if curpage > #tab_top then
        curpage = 1;
    end
    --activityPage.transform:DOLocalMoveX((curpage-1)*-720-360,0.4,false);
    this.ClickPage();
end]]

function UISupSkill.onClickChangePage()
    --local go = Data.data
    --local index = content:GetChildIndex(go)
    AudioManager.Play(2026)
    local curData = allSkillData[skillIdx + 1]
    local skillData = G.dataTable["t_skill"][tostring(curData.id)];
    this.effectController.selectedIndex = 0
    consumeList.itemRenderer = this.rendererConsume
    consumeList.numItems = #curData.data.f_Cost
    local curGroup = skillGroup[curData.data.f_AssistantSkillGroup];
    if #curGroup < SkillManager.supSkillLv + 1 then
        --满级
        consumeList.visible = false
        this.btnSource.visible = false
        upgradeController.selectedIndex = 1
        levelMaxCtrl.selectedIndex = 1
        previewCtrl.selectedIndex = 0
    else
        consumeList.visible = true
        this.btnSource.visible = true
        upgradeController.selectedIndex = 0
        levelMaxCtrl.selectedIndex = 0
    end
    skillTipsText.text = getLanguage(skillData.f_Desc)
    skillNameText.text = getLanguage(skillData.f_SkillName)
    skillLevelText.text = SkillManager.supSkillLv
    this.refreshAttrData(curData)
    curAttrList.itemRenderer = this.rendererCurAttrList
    curAttrList.numItems = #this.curAttr
    nextAttrList.itemRenderer = this.rendererNextAttrList
    nextAttrList.numItems = #this.nextAttr
    this.initTop(skillIdx, tipsIcon, 1)
    --resetBtn.visible = curData.info ~= nil and curData.info.skillLev > 1
end

function UISupSkill.rendererConsume(idx, obj)

    local curData = allSkillData[skillIdx + 1].data.f_Cost[idx + 1];
    local itemData = G.dataTable["t_item"][tostring(curData[1])];
    local icon = obj:GetChild("ItemIcon")
    local num = obj:GetChild("ItemText")
    local btnJump = obj:GetChild("btnJump")

    icon.url = "ui://ItemAtlas/" .. itemData.f_Icon
    local hasNum = logicMgr.ItemManager.getCurrencyCountByModelId(curData[1])
    if hasNum < curData[2] then
        hasNum = HelperFunc.Format4ResourceNum(hasNum)
        if not logicMgr.ItemManager.getSourceStart("UISupSkill") then
            this.effectController.selectedIndex = 1
        end
        isCanUpgrade = true;
        hasNum = "[color=#FF0000]" .. hasNum .. "[/color]"
    else
        isCanUpgrade = true
        hasNum = HelperFunc.Format4ResourceNum(hasNum)
    end

    num.text = hasNum .. "/" .. curData[2]
    btnJump.onClick:Clear()
    btnJump.onClick:Add(function()
        this.onClickGetCost(idx + 1)
    end)
    this.costIdList[idx + 1] = curData[1]
end

function UISupSkill.initPapers()
    content:SetVirtualAndLoop();
    allSkillData = {};
    allSkillItems = {};
    content.itemRenderer = this.initTop;
    content.numItems = #skillGroup;
    if not isScroll then
        isScroll = true;
        content:ScrollToView(#skillGroup + 1);
    end

    content.scrollPane.onScroll:Add(this.doSpecialEffect);
    content.scrollPane.onScrollEnd:Add(this.onScrollEnd);
    this.doSpecialEffect();
    this.onScrollEnd();
end

function UISupSkill.initTop(index, obj, isShow)

    local skillName = obj:GetChild("SkillName");
    local lockController = obj:GetController("c2");
    local headIcon = obj:GetChild("Mask"):GetChild("Icon");
    local lockText = obj:GetChild("LockText");
    local lockTypeController = obj:GetController("lockType");

    local groupData = skillGroup[index + 1]
    local data = {}
    data.id = 0
    for i = 1, #groupData do
        for j = 1, #skillInfo do
            if skillInfo[j].skillId == groupData[i].f_AssistantSkillId then
                data.id = skillInfo[j].skillId;
                data.data = groupData[i];
                data.info = skillInfo[j];
                break;
            end
        end
    end

    if data.info ~= nil then
        lockController.selectedIndex = 0
    else
        data.id = groupData[SkillManager.supSkillLv].f_AssistantSkillId
        data.data = groupData[SkillManager.supSkillLv]
        lockController.selectedIndex = 1
        lockTypeController.selectedIndex = data.data.f_GetCondition[1][1] - 1
        local stageConfig = G.dataTable["t_stage"]
        local mapCfg = stageConfig[tostring(data.data.f_GetCondition[1][2])]
        lockText.text = mapCfg.f_ChapterId .. "-" .. mapCfg.f_StageNum
    end
    local skillData = G.dataTable["t_skillshow"][tostring(data.id)]
    headIcon.url = "ui://SkillAtlas/" .. skillData.f_SkillIcon
    skillName.text = skillData.f_SkillName
    allSkillData[index + 1] = data
    --local icon = obj:GetChild("icon");
    if isShow == nil then
        obj:SetPivot(0.5, 0.5);
    end

    --local name = obj:GetChild("name");
    --local frame = obj:GetChild("frame");
    --name.url = "ui://UISupSkill/summon_form_text_" .. tab_top[index + 1];
    --frame.url = "ui://UISupSkill/summon_form_frame_" .. tab_top[index + 1];
    --icon.url = "ui://UISupSkill/summon_form_kp_" .. tab_top[index + 1];
    ----if index + 1 == curpage then
    ----    obj.selected = true
    ----end
end

function UISupSkill.onScrollEnd()
    local chooseMid = (content:GetFirstChildInView() + 1) % content.numItems
    skillIdx = chooseMid + 2 >= #skillGroup and chooseMid + 2 - #skillGroup or chooseMid + 2
    indexController:SetSelectedIndex(skillIdx);
    --curItem = content:GetChildAt(skillIdx);
    curItem:GetController("c1").selectedIndex = 1;
    local chooseEffect = curItem:GetChild("zyxt_effect");
    --upAni.spineAnimation.state.Data.SkeletonData:FindAnimation("idle2").Duration
    local effectAniState = chooseEffect.spineAnimation.state;
    effectAniState:SetAnimation(0, "idle", false);
    --content:GetChildAt(chooseMid).sortingOrder = content:GetChildAt(chooseMid).sortingOrder + 9999;
    --this.doSpecialEffect();
    --local midX = content.scrollPane.posX + content.viewWidth / 2;
    --local dist = midX  - obj.width / 2;
    --print("dist:"..dist);
    --
    --
    --if not isScroll then
    --    content.scrollPane:SetPosX(dist  ,true);
    --    isScroll = true;
    --else
    --    isScroll = false;
    --end
    this.onClickChangePage();
end

function UISupSkill.doSpecialEffect()
    local midX = content.scrollPane.posX + content.viewWidth / 2;
    --local chooseMid = (content:GetFirstChildInView() + 1) % content.numItems;
    --content:GetChildAt(chooseMid).sortingOrder = content:GetChildAt(chooseMid).sortingOrder - 9999;
    for i = 1, content.numChildren do
        local obj = content:GetChildAt(i - 1);
        local dist = math.abs(midX - obj.x - obj.width / 2);
        if dist > obj.width * 3 then
            obj:SetScale(0.8, 0.8);
        else
            local changeScale = 0.8 + (1 - dist / obj.width) * 0.2;
            obj:SetScale(changeScale, changeScale);
        end
        if (1 - dist / obj.width) >= 0.90 then
            curItem = obj;
            local chooseMid = (content:GetFirstChildInView() + 1) % content.numItems;
            skillIdx = chooseMid + 2 >= #skillGroup and chooseMid + 2 - #skillGroup or chooseMid + 2;
            indexController:SetSelectedIndex(skillIdx);

        else
            obj:GetController("c1").selectedIndex = 0;
        end
        --if chooseMid < i then
        --    obj.sortingOrder = chooseMid - (chooseMid - i)
        --elseif chooseMid == i then
        --    obj.sortingOrder = chooseMid;
        --elseif chooseMid > i then
        --    obj.sortingOrder = chooseMid - (i - chooseMid);
        --
        --end
    end
    --if chooseMid ~= (content:GetFirstChildInView() + 1) % content.numItems then
    --    chooseMid = (content:GetFirstChildInView() + 1) % content.numItems;
    --    this.onClickChangePage(chooseMid);
    --end


end

function UISupSkill.onClickGetCost(key)
    --showUI(PanelNames.UISource, function ()
    --    this.onClose();
    --end, this.costIdList[key]);
    this.showSourceController.selectedIndex = 1;
    this.showSourceList = { this.costIdList[key] }
    logicMgr.ItemManager.setSourceStart("UISupSkill", true)
    this.effectController.selectedIndex = 0;
    this.updateSource();
end

function UISupSkill.updateSource()
    logicMgr.ItemManager.updateSourceUI(this.sourceUIobj, this.showSourceList, function()
        this.showSourceController.selectedIndex = 0;
    end, function()
        this.showSourceController.selectedIndex = 0;
        this.onClose();
    end);
end

function UISupSkill.onClickSource()
    --logicMgr.ItemManager.updateSourceUI(this.sourceUIobj, this.costIdList, function ()
    --end, function ()
    --    this.onClose();
    --end );
    this.onClickGetCost(1);
end

function UISupSkill.onClickResetSkill()
    local data = {}
    data.id = allSkillData[skillIdx + 1].id;
    showUI(PanelNames.UICharactorReborn, data, 1);

    --skillHandler.SendReqResetSkill(allSkillData[skillIdx + 1].id)
end

function UISupSkill.refreshShop()
    this.btnShop.visible = false;
    local actState = logicMgr.CostManager.getFastConsumption();
    if actState == 0 or (actState == 1 and logicMgr.CostManager.isFastConsumptionItems(5)) then
        this.btnShop.visible = true;
    end
end

function UISupSkill.onClickShop()
    showUI(PanelResNames.UIGiftLink, 5, -1, function()
        this.onClickChangePage();
    end);
end

function UISupSkill.refreshAttrData(curData)
    if curData and curData.id and tonumber(curData.id) > 0 then
        this.curAttr = {}
        this.nextAttr = {}
        local curAttrData = decodeJsonStrToTabel(G.dataTable["t_assistantskill"][tostring(curData.id)].f_ParaShow)
        local nextAttrData = nil
        local curGroup = skillGroup[curData.data.f_AssistantSkillGroup]
        if #curGroup >= SkillManager.supSkillLv + 1 then --还未升到满级
            nextAttrData = decodeJsonStrToTabel(G.dataTable["t_assistantskill"][tostring(curData.id + 1)].f_ParaShow)
        end
        if attributeShowConfig == nil then
            attributeShowConfig = G.dataTable["t_attributelibrary"];
        end
        if curAttrData then
            local temp = {}
            for _,v in pairs(curAttrData) do
                temp[v[1]] =  v[2]
            end
            local tempCurAttr = temp
            for k,v in pairs(tempCurAttr) do
                local attributeItemConfig = attributeShowConfig[tostring(k)];
                if attributeItemConfig.f_IsPanel ==1 then
                    local item = {}
                    item.v = v
                    item.k = k
                    table.insert(this.curAttr,item)
                end
            end
        end

        if nextAttrData then
            local temp = {}
            for _,v in pairs(nextAttrData) do
                temp[v[1]] =  v[2]
            end
            local tempNextAttr = temp
            for k,v in pairs(tempNextAttr) do
                local attributeItemConfig = attributeShowConfig[tostring(k)];
                if attributeItemConfig.f_IsPanel ==1 then
                    local item = {}
                    item.v = v
                    item.k = k
                    table.insert(this.nextAttr,item)
                end
            end
        end
    end
end

function UISupSkill.onClickPreview()
    if previewCtrl.selectedIndex == 0 then
        previewCtrl.selectedIndex = 1
    else
        previewCtrl.selectedIndex = 0
    end
end

function UISupSkill.rendererCurAttrList(index, go)
    local attr = this.curAttr[index+1].v
    local attributeItemConfig = attributeShowConfig[tostring(this.curAttr[index+1].k)];
    if attributeItemConfig.f_IsPanel ==1 then
        local ctrlItem = CtrlManager.GetCtrl(PanelNames.UICharactorAttributeDetailsItem);
        if ctrlItem ~=nil and go~=nil then
            local data = {
                name = getLanguage(string.format(Config.LangAttribute,this.curAttr[index+1].k)),
                value = attr,
                type = attributeItemConfig.f_AttributeType,
                icon = "attr"..this.curAttr[index+1].k
            };
            ctrlItem.initData(go,data);
        end
    end
end

function UISupSkill.rendererNextAttrList(index, go)
    local attr = this.nextAttr[index+1].v
    local attributeItemConfig = attributeShowConfig[tostring(this.nextAttr[index+1].k)];
    if attributeItemConfig.f_IsPanel ==1 then
        local ctrlItem = CtrlManager.GetCtrl(PanelNames.UICharactorAttributeDetailsItem);
        if ctrlItem ~=nil and go~=nil then
            local data = {
                name = getLanguage(string.format(Config.LangAttribute,this.nextAttr[index+1].k)),
                value = attr,
                type = attributeItemConfig.f_AttributeType,
                icon = "attr"..this.nextAttr[index+1].k
            };
            ctrlItem.initData(go,data);
        end
    end
end

return UISupSkill;